{% extends "page_templates/banner_base.html" %}
{% load facebook_tags %}
{% block intro_video %}
	<div class="video">
		<iframe title="YouTube video player" width="410" height="250" src="http://www.youtube.com/embed/xI43tzUD2lU" frameborder="0" allowfullscreen></iframe>
	</div>
{% endblock %}
{% block search_block %}
	<body>
	<h2>Find a game near you! {{ logged_in_user.first_name }}</h2>
	<form action="." method="GET">
		{% csrf_token %}
		{{ searchform.non_field_errors }}
		<div class="fieldWrapper">
			{{ searchform.game.errors }}
			<label for="id_game">*Game: </label>
			{{ searchform.game }}
		</div>
		<p>
		{{ searchform.city.errors }}
		<label for="id_city">City: </label>
		{{ searchform.city }}
		&nbsp;
		{{ searchform.state.errors }}
		<label for="id_state">State: </label>
		{{ searchform.state }} 
		&nbsp;
		{{ searchform.zipcode.errors }}
		<label for="id_zipcode">or Zip: </label>
		{{ searchform.zipcode }}
		</p>
		<p><input type="submit" value="Search"></p>
	</form>

	<p style="font-size:10px">* required field</p>
	{% if city_query and not zip_query %}
		<h3>Search Results:</h3>
		{% if results %}
			{% for result in results %}
				<hr/>
				<div class="search_result">
					{% if result.private %}
						<p>
						<b><u>{{ result.label }}</u><br/>
						Organizer: </b>{{ result.organizer }}
						&nbsp;Private Game
						</p>
						<form action="/home/" method="GET">
							<input type="hidden" name="game" value="{{ game_query }}" />
							<input type="hidden" name="city" value="{{ city_query }}" />
							<input type="hidden" name="state" value="{{ state_query }}" />
							<input type="hidden" name="zipcode" value="{{ zip_query }}" />
							{{ passform.non_field_errors }}
							{{ passform.passwd.errors }}
							<label for="passwd">Password: </label>
								<input type="password" name="passwd" value="{{ pass_query }}">
								<input type="submit" value="Submit">
						</form>
						{% if pass_query == result.password %}
							{% if result.game.name|lower == 'basketball' %}
								<img src="http://pickupsports.1829.a.hostable.me/basketball.png" height="100" />
							{% endif %}
							{% if result.game.name|lower == 'baseball' %}
								<img src="http://pickupsports.1829.a.hostable.me/baseball.gif" height="100" />
							{% endif %}
							{% if result.game.name|lower == 'soccer' %}
								<img src="http://pickupsports.1829.a.hostable.me/soccer.png" height="100" />
							{% endif %}
							{% if result.game.name|lower == 'tennis' %}
								<img src="http://pickupsports.1829.a.hostable.me/tennis.png" height="100" />
							{% endif %}
							{% if result.game.name|lower == 'football' %}
								<img src="http://pickupsports.1829.a.hostable.me/football.png" height="100" />
							{% endif %}
							<p>
							<b><u>{{ result.label }}</u></br>
							Organizer: </b>{{ result.organizer }} <br/>
							<b>Game: </b>{{ result.game }}
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<b>Location: </b>{{ result.city }}, {{result.state}} {{ result.zipcode }} {{result.informal_location}}
							<br/>
							<b>Player Limit: </b>{{ result.player_limit }}
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<b>Date: </b>{{ result.date }}
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							{% if result.recurring %}
								<b>Recurring: </b>Yes, {{ result.recurring_details }}
							{% else %}
								<b>Recurring: </b>No
							{% endif %}
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<b>Details: </b>{{ result.game_details }}
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<b>Intensity: </b>{{ result.intensity }}
							</p>
							{% if logged_in_user %}
							<form action="." method="GET">
								<input type="hidden" name="a" value="{{ result.unique }}">
								<input type="hidden" name="b" value="{{ logged_in_user.username }}"> 
								<input type="submit" value="Join!">
							</form>
							{% else %}
								<p>Login to join games!</p>
							{% endif %}
						{% endif %}
					{% else %}
						{% if result.game.name|lower == 'basketball' %}
							<img src="http://pickupsports.1829.a.hostable.me/basketball.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'baseball' %}
							<img src="http://pickupsports.1829.a.hostable.me/baseball.gif" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'soccer' %}
							<img src="http://pickupsports.1829.a.hostable.me/soccer.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'tennis' %}
							<img src="http://pickupsports.1829.a.hostable.me/tennis.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'football' %}
							<img src="http://pickupsports.1829.a.hostable.me/football.png" height="100" />
						{% endif %}
						<p>
						<b><u>{{ result.label }}</u></br>
						Organizer: </b>{{ result.organizer }} <br/>
						<b>Game: </b>{{ result.game }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Location: </b>{{ result.city }}, {{result.state}} {{ result.zipcode }} {{result.informal_location}}
						<br/>
						<b>Player Limit: </b>{{ result.player_limit }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Date: </b>{{ result.date }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						{% if result.recurring %}
							<b>Recurring: </b>Yes, {{ result.recurring_details }}
						{% else %}
							<b>Recurring: </b>No
						{% endif %}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Details: </b>{{ result.game_details }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Intensity: </b>{{ result.intensity }}
						</p>
						{% if logged_in_user %}
						<form action="." method="GET">
							<input type="hidden" name="a" value="{{ result.unique }}">
							<input type="hidden" name="b" value="{{ logged_in_user.username }}"> 
							<input type="submit" value="Join!">
						</form>
						{% else %}
							<p>Login to join games!</p>
						{% endif %}
					{% endif %}
				</div>
			{% endfor %}
			<hr/>
		{% else %}
			<h5>Nothing found</h5>
		{% endif %}
	{% endif %}
	{% if zip_query %}
		<h4>Search Results:</h4>
		{% if results %}
			{% for result in results %}
				<hr/>
				<div class="search_result">
					{% if result.private %}
						<p>
						<b><u>{{ result.label }}</u><br/>
						Organizer: </b>{{ result.organizer }}
						</p>
						<p>Private Game, need password: </p>
					{% else %}
						{% if result.game.name|lower == 'basketball' %}
							<img src="http://pickupsports.1829.a.hostable.me/basketball.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'baseball' %}
							<img src="http://pickupsports.1829.a.hostable.me/baseball.gif" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'soccer' %}
							<img src="http://pickupsports.1829.a.hostable.me/soccer.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'tennis' %}
							<img src="http://pickupsports.1829.a.hostable.me/tennis.png" height="100" />
						{% endif %}
						{% if result.game.name|lower == 'football' %}
							<img src="http://pickupsports.1829.a.hostable.me/football.png" height="100" />
						{% endif %}
						<p>
						<b><u>{{ result.label }}</u></br>
						Organizer: </b>{{ result.organizer }} <br/>
						<b>Game: </b>{{ result.game }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Location: </b>{{ result.city }}, {{result.state}} {{ result.zipcode }} {{result.informal_location}}
						<br/>
						<b>Player Limit: </b>{{ result.player_limit }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Date: </b>{{ result.date }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						{% if result.recurring %}
							<b>Recurring: </b>Yes, {{ result.recurring_details }}
						{% else %}
							<b>Recurring: </b>No
						{% endif %}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Details: </b>{{ result.game_details }}
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<b>Intensity: </b>{{ result.intensity }}
						</p>
						{% if logged_in_user %}
							<form action="." method="GET">
								<input type="hidden" name="a" value="{{ result.unique }}">
								<input type="hidden" name="b" value="{{ logged_in_user.username }}"> 
								<input type="submit" value="Join!">
							</form>
						{% else %}
							<p>Login to join games!</p>
						{% endif %}
					{% endif %}
				</div>
			{% endfor %}
			<hr/>
		{% else %}
			<h5>Nothing found</h5>
		{% endif %}
	{% endif %}
	{% if joined_game %}
		<h6>Joined game {{ joined_game_label}}!<h6>
	{% else %}
	
	{% endif %}
	</body>
{% endblock %}
